#include <my_header.h>
#if 0
因为 ret_join 实际上代表的是 pthread_join 函数的返回值，它将在成功时返回 0。因此，如果你想看到子线程返回的正确值 10，你必须使用前面建议的打印语句。
#endif
/* Usage: ./8_pthread_join4 */
void *threadFunc(void *arg)
{
    sleep(5);

    int *num = (int *)malloc(sizeof(int));
    ERROR_CHECK(num, NULL, "malloc");
    *num  = 10;

    return (void *)num;
}
int main(void){                                  
    pthread_t tid;
    int ret = pthread_create(&tid, NULL,threadFunc,NULL);
    THREAD_ERROR_CHECK(ret, "pthread_create");

    void *retThread;
    int ret_join = pthread_join(tid, &retThread);
    THREAD_ERROR_CHECK(ret_join, "pthread_join");
    printf("child threadrd retval =%d\n", ret_join);
    // printf("child thread retval = %d\n", *(int *)retThread);
    // 及时释放子进程的堆
    free(retThread);

    return 0;
}


